<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>商户微信被扫交易</title>
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript" src="encrypt.js"></script>
</head>
<body>
	<center>
		<form>
			<input type="hidden" name="bizcode" value="1003">
			<table cellpadding="10">
				<tr>
					<td>订单号</td>
					<td><input type="text" name="tranxSN" value="201608" autofocus="autofocus"></td>
				</tr>
				<tr>
					<td>交易标题</td>
					<td><input type="text" name="subject"></td>
				</tr>
				<tr>
					<td>会员号</td>
					<td><input type="text" name="memberNo" value="G100117097221966"></td>
				</tr>
				<tr>
					<td>交易金额</td>
					<td><input type="text" name="transAmt"></td>
				</tr>
			</table>
		</form>
			<button onclick="transaction()">交易</button>
			<br />
			<div id="qrcode">
	</center>
</body>
	<script type="text/javascript">
		function transaction(){
			$.ajax({
		        type: "POST",
		        url: "MemberTransaction",
		        dataType: 'json', 
		        data: encrypt($('form').serializeArray()),
		        success: function(data) {
		        	if(data.respCode=="0000"){
		        		var qrcode = new QRCode(document.getElementById("qrcode"), { width : 96,  height : 96 });
		                qrcode.makeCode(data.codeUrl);
		        		var connection = new WebSocket('ws://renne66.imwork.net:28798/unifypay/TransactionWebsocket/'+data.tranxSN);
		        		connection.onmessage=function(event){
		        			$("#qrcode").html(event.data == "0000" ? "交易成功" : "交易失败");
		        			connection.close();
		        		}
		        	}
		        }
		    });
		}
	</script>
</html>